<template>
    <div>
        <div class="search">
        <header>
            <h4>探索</h4>
        </header>
        <section>
            <div class="search-box">
                <span class="icon"></span>
                <input type="text">
                <i></i>
            </div>
        </section>
        <nav>
            <div class="title">音乐风格</div>
            <ul>
                <li>舞蹈</li>
                <li>流行</li>
                <li class="active">拉丁</li>
                <li>爵士</li>
                <li>电子</li>
            </ul>
            <ul>
                <li>复古</li>
                <li>轻快</li>
                <li>轻快</li>
                <li>轻快</li>
                <li>轻快</li>
            </ul>
        </nav>
        <nav>
            <div class="title">情感伤怀</div>
            <ul>
                <li>沉思</li>
                <li>聚会</li>
                <li>家庭</li>
                <li>感情</li>
            </ul>
        </nav>
       
    </div>

     <!--  最新歌曲-->
     <new-songs :songs="newSongs"></new-songs>

     <div style="padding-bottom: 100px;"></div>
    </div>
</template>

<script>
import NewSongs from "@/components/NewSongs.vue"
// 导入接口
import {  newsongFn} from '@/api/index'
export default {
    data(){
        return {
            newSongs: []
        }
    },
    components: {
        NewSongs,
    },
    methods: {
         // 获取新音乐
         async newsongFunc(){
            await newsongFn()
            .then(
                content=>{
                    // console.log("6.0",content)
                    let {code , result } = content;
                    if(code==200){
                        // console.log("7.0",result)
                        let arr = result.map(item=>{
                            let id = item.id;
                            let title = '最新音乐'
                            let artist = { picUrl: item.picUrl}
                            let name = item.name;
                            let type = 'newsong';
                            let path = '/home/list'
                            return {
                                id,
                                title,
                                artist,
                                name,
                                type,
                                path
                            }
                        })
                        // 进行赋值
                        this.newSongs = arr;
                    }
                }
            )
        }
    },
    created(){
        // 初始化
        this.newsongFunc()
    }
}
</script>

<style lang="less">
@import "@/static/less/variable.less";
.search {
    padding: @pad;
    header {
        height: 60px;
        display: flex;
        align-items: center;
        h4 {
            font-weight: normal;
            font-size: 20px;
        }
    }
    section {
        .search-box {
            width: 100%;
            position: relative;
            input {
                width: 100%;
                height: 56px;
                border-radius: 10px;
                padding: 0 20px 0 40px;
                box-sizing: border-box;
                font-size: 16px;
            }
            span , i  {
                position: absolute;
                top: 15px;
                width: 26px;
                height: 26px;
                background-size: cover;
            }
            span {
                left: 10px;
                background-image: url(../../static/images/Search@2x.png);
            }
            i {
                right: 10px;
                background-image: url(../../static/images/Icon_Outline_X.png);
            }
        }
    }

    nav {
        width: 100%;
        width: 100%;
        overflow: scroll;
        .title {
            padding: 10px 0;
            font-size: 16px;
        }
        ul {
            width: 120%;
            ::-webkit-scrollbar {
                display: none;
                width: 0;
                height: 0;
            }
            display: flex;
            li {
                font-size: 15px;
                flex-shrink: 0;
                padding: 15px 25px;
                margin:5px 5px;
                background-color: #f0f0f0;
                border-radius: 10px;
            }
            .active {
                background-color: @bgColor;
                color: #fff;
            }
        }
    }
}
</style>